//
// Created by lanlu on 2025/8/6.
//
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

class Solution {
public:
    long long maximumProduct(vector<int>& nums, int m) {
        if (m == 1)
        {
            long long maxVal = LLONG_MIN;
            for (int i = 0; i < nums.size(); i++)
            {
                maxVal = max(maxVal, (long long)nums[i] * nums[i]);
            }
            return maxVal;
        }

        // m > 1
        long long maxVal = LLONG_MIN;
        // 这里i代表左边界 j代表右边界
        // 如果m=2 nums.size()=4  0,1,2,3
        for (int i = 0; i <= nums.size() - m; i++)
        {
            for (int j = i + m - 1; j < nums.size(); j++)
            {
                maxVal = max(maxVal, (long long)nums[i] * nums[j]);
            }
        }
        return maxVal;
    }
};